﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="news_list_manage.aspx.cs" Inherits="Ccit.OA.NewsCenter.news_list_manage" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.1" Namespace="DevExpress.Web.ASPxGridView"
    TagPrefix="dxwgv" %>

<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>信息中心-信息管理</title>
    <script language="javascript" type="text/javascript" src="../script/jsonlib.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jwindow.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jbase64.js"></script>
    
    <script type="text/javascript" language="javascript">
       /* New OR Edit News */
        function doModify(oNewsId)
        {
            var oNewsType=document.getElementById("_hidType").value;
            var vPageParam;
            var encodeParam;
            if(oNewsId=="")
            {
                vPageParam = "Type="+oNewsType+"&From=0";
                encodeParam = base64encode(vPageParam);
                window.location.href="news_submit_edit.aspx?" + encodeParam;
            }
            else
            {
                vPageParam = "Type="+oNewsType+"&Id="+oNewsId+"&From=1";
                encodeParam = base64encode(vPageParam);
                window.location.href="news_submit_edit.aspx?" + encodeParam;
            }
        }
        
        function doComment(oNewsId)
        {
            var oNewsType=document.getElementById("_hidType").value;
            vPageParam = "Type="+oNewsType+"&Id="+oNewsId+"&Pur=Manage";
            var encodeParam=base64encode(vPageParam);
            OpenWindow("news_comments_management.aspx?"+encodeParam,"",1000,700);
        }
        
        /* Delete News */
        function doDelete(oNewsIds)
        {
            var oType=document.getElementById("_hidType").value;
            if(oNewsIds=="")
            {
                oNewsIds=document.getElementById("hdIds").value;
                if(oNewsIds=="")
                {
                    alert("请选择要删除的信息！");
                    return;
                }
                else
                {
                    if(confirm("确认要删除选择的信息？"))
                        PageMethods.OperateNews(oNewsIds,"DELETE","",oType,ClientCallBack);
                }
            }
            else
            {
                if(confirm("确认要删除该信息？"))
                    PageMethods.OperateNews(oNewsIds,"DELETE","",oType,ClientCallBack);
            }
        }
        
        /* Submit News */
        function doPublic()
        {
            var oType=document.getElementById("_hidType").value;
            var oNewsIds=document.getElementById("hdIds").value;
            if(oNewsIds=="")
            {
                alert("请选择要提交的信息！");
                return;
            }
            else
            {
                if(confirm("信息提交后将不能进行编辑，是否确认提交所选择的信息？"))
                    PageMethods.OperateNews(oNewsIds,"PUBLIC","",oType,ClientCallBack);
            }
        }
        
        // 信息撤销
        function doRevocation()
        {
            var oType=document.getElementById("_hidType").value;
            var oNewsIds=document.getElementById("hdIds").value;
            if(oNewsIds=="")
            {
                alert("请选择要撤销的信息！");
                return;
            }
            else
            {
               PageMethods.OperateNews(oNewsIds,"REVOCATION","",oType,ClientCallBack);
            }
        }
        
        //信息退回
        function doReturn()
        {
            var oType=document.getElementById("_hidType").value;
            var oNewsIds=document.getElementById("hdIds").value;
            if(oNewsIds=="")
            {
                alert("请选择要退回的信息！");
                return;
            }
            else
            {
               PageMethods.OperateNews(oNewsIds,"RETURN","",oType,ClientCallBack);
            }
        }
        
        
        /* Set Search Condition */
        function doSetCondition()
        {
            var oType=document.getElementById("_hidType").value;
            var vPageParam = "Type="+oType+"&PageSource=3";
            var encodeParam = base64encode(vPageParam);
            window.location.href="news_queryset_frame.aspx?" + encodeParam;
        }
        
        function ClientCallBack(oRetResult)
        {
            eval("var oResult="+oRetResult);
            var oExeResult=oResult.ExeResult;
            var oOperType=oResult.OperType;
            if(oOperType=="DELETE")
            {
                if(oExeResult)
                {
                    alert("删除成功！");
                    doRefresh();
                }
                else
                {
                    alert("删除失败，请稍后再试！");
                }
            }
            else if(oOperType=="PUBLIC")
            {
                if(oExeResult)
                {
                    alert("发布成功！");
                    doRefresh();
                }
                else
                {
                    alert("发布失败，请稍后再试！");
                }
            }
            else if(oOperType=="TOPFLAG")
            {
                if(!oExeResult)
                {
                    alert("更改置顶状态失败，请稍后再试！");
                }
                else
                {
                    doRefresh();
                }
            }
            else if(oOperType == "REVOCATION")
            {
               if(oExeResult)
                {
                    alert("撤销成功！");
                    doRefresh();
                }
                else
                {
                    alert("撤销失败，请稍后再试！");
                }
            }else if(oOperType == "RETURN")
            {
               if(oExeResult)
                {
                    alert("信息退回成功！");
                    doRefresh();
                }
                else
                {
                    alert("信息退回失败，请稍后再试！");
                }
            }
            
        }
        
        /* New View */
        function doViewNews(oNewsId)
        {
            var vPageParam = "Id="+oNewsId;
            var encodeParam = base64encode(vPageParam);
            OpenWindow("news_inform_view.aspx?"+encodeParam,"","1000","700");
        }
        
        /*  change and Upload Picture  */
        function doChangePic(oNewsId)
        {
            var oType=document.getElementById("_hidType").value;
            var vPageParam = "at=1&Type="+oType+"&Id="+oNewsId+"&RefreshOpener=1&FuncName=doRefresh";
            //var encodeParam = base64encode(vPageParam);
            OpenWindow("news_submit_addpic.aspx?"+vPageParam,"",440,400,false);
        }
        
        /*  change topflag  */
        function doChangeTopFlag(oNewsId,oCurrTopFlag)
        {
            var oType=document.getElementById("_hidType").value;
            PageMethods.OperateNews(oNewsId,"TOPFLAG",oCurrTopFlag,oType,ClientCallBack);
        }
        
        /*  Show Current News ViewInfo  */
        function doShowViewInfo(oNewsId)
        {
            var vPageParam = "Id="+oNewsId;
            var encodeParam = base64encode(vPageParam);
            OpenWindow("news_viewstat_list.aspx?"+encodeParam,"","1000","700");
        }
        
        /* Refresh current page */
        function doRefresh()
        {
            __doPostBack("lnkSearch","");
        }
       
    </script>
    
</head>
<body>
    <ccit:ActionForm id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server"></asp:ScriptManager>
    <input type="hidden" id="_hidType" runat="server" />
    <input type="hidden" id="_hidTabId" runat="server" />
    <%-- 选择的信息ID串 --%>
    <input type="hidden" id="hdIds" runat="server" />
    <table class="tbToolbar" cellpadding="0" cellspacing="0" align="center" width="98%">
            <tr>
                <td align="left">
                    <div class="tbSeparator"></div>                    
                </td>
                <td align="left" class="titlebar">
                    <nobr>信息中心-信息管理</nobr>
                </td>
                <td style="width:98%" align="right">
                    <nobr>
                        快捷条件
                        <asp:DropDownList ID="ddlManageNews" CssClass="inputselect" runat="server" Width="150px"></asp:DropDownList>
                        <asp:LinkButton ID="lnkSearch" CssClass="linktext" runat="server" 
                        onclick="lnkSearch_Click" >
                            <img src="../images/toolbar/search.gif" />查询
                        </asp:LinkButton>
                        <a id="A2" href="javascript:doDelete('')" class="linktext" runat="server"><img src="../images/toolbar/16X16/delete.gif" />删除</a>
                        <a id="A3" href="javascript:doPublic('')" class="linktext" runat="server"><img src="../images/toolbar/right.gif" />发布</a>
                        <a id="A1" href="javascript:doRevocation('')" class="linktext" runat="server"><img src="../images/toolbar/right.gif" />撤销</a>
                        <a id="A5" href="javascript:doReturn('')" class="linktext" runat="server"><img src="../images/toolbar/right.gif" />退回</a>
                        <a id="A4" href="javascript:doSetCondition()" class="linktext" runat="server"><img src="../images/toolbar/bdgsdy/design.gif" />设置查询条件</a>
                    </nobr>
                </td>
                <td align="right">
                    <div class="tbSeparatorEnd"></div>
                </td>
            </tr>
        </table>
        
    <dxwgv:ASPxGridView ID="gvNewsManagerList" align="center" Width="98%"  
        KeyFieldName="NewsId" runat="server" 
        onhtmlrowcreated="gvNewsManagerList_HtmlRowCreated">
         <Columns>
                <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="2%">
                    <HeaderTemplate>
                        <input id="chkCheck" type="checkbox" runat="server" onclick="gvNewsManagerList.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Select/Unselect all rows on the page"></input>
                    </HeaderTemplate>
                    <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" HorizontalAlign="Center">
                        <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                    </HeaderStyle>
                </dxwgv:GridViewCommandColumn>
                <dxwgv:GridViewDataTextColumn Caption="信息标题" FieldName="NewsTitle" VisibleIndex="0" Width="20%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="left"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="信息栏目" FieldName="ColumnNo" VisibleIndex="1" Width="15%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="left"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="信息状态" FieldName="NewsStatus" VisibleIndex="2" Width="10%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="图片" FieldName="PicFlag" VisibleIndex="3" Width="5%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="置顶" FieldName="TopFlag" VisibleIndex="4" Width="5%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="阅读人数" FieldName="ViewCount" VisibleIndex="5" Width="5%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="评论管理" FieldName="CommentCount" VisibleIndex="5" Width="5%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="发布时间" FieldName="IssueDate" VisibleIndex="6" Width="20%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                
                <dxwgv:GridViewDataTextColumn Caption="操作" VisibleIndex="7" Width="13%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                    <DataItemTemplate>
                        <a id="haModify" runat="server">编辑</a>&nbsp;
                        <a id="haDelete" runat="server">删除</a>
                    </DataItemTemplate>
                </dxwgv:GridViewDataTextColumn>
            </Columns>
            <SettingsPager AlwaysShowPager="True" PageSize="15">
                <FirstPageButton Visible="True">
                </FirstPageButton>
                <LastPageButton Visible="True">
                </LastPageButton>
            </SettingsPager>
            <Styles>
                <Row CssClass=""></Row>
                <AlternatingRow  CssClass="" Enabled="true"/>
                <SelectedRow  CssClass=""></SelectedRow>
            </Styles>
            <%-- 复选框选择脚本事件 --%>
            <ClientSideEvents SelectionChanged="function(s,e){OnGridSelectionChanged();}"/>
    </dxwgv:ASPxGridView>
     <script language="javascript" type="text/javascript">
        <!--
        ///复选框选择
        function OnGridSelectionChanged(){
            gvNewsManagerList.GetSelectedFieldValues("NewsId",OnGridSelectionComplete);
        }
        
        function OnGridSelectionComplete(values){
            document.getElementById("hdIds").value = values;
        }
        //-->
    </script>
    </ccit:ActionForm>
</body>
</html>
